package beastick.utility;

//Copyright 2008 Tofig Kareemov, estereos@gmail.com
//
//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
//
//http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.

public class CPrint extends CUtilityMethods
{
  private final String S_EOL = "\r\n";
  protected final int I_PRINT_TYPE_CONSOLE = 1;
  protected final int I_PRINT_TYPE_STRING = 2;
  protected int iPrintType = 0;
  protected int iPrintIterator = 0;
  protected String sPrintPattern = "";
  protected String sPrintOutput = "";

  private String ProcessInput(String sInput)
  {
    CStringParameterizer oParamString = new CStringParameterizer();

    ++iPrintIterator;
    oParamString.LoadPattern(sPrintPattern);
    oParamString.ParameterCompiled("%VALUE%", sInput);
    oParamString.ParameterCompiled("%LINENUMBER%", "" + iPrintIterator);
    oParamString.DateVersionCompiled();
    oParamString.TimeVersionCompiled();
    return oParamString.Get();
  }

  protected final String GetOutput()
  {
    return sPrintOutput;
  };

  protected final void Println(String sInput)
  {
    if (iPrintType == I_PRINT_TYPE_CONSOLE)
    {
      System.out.println(ProcessInput(sInput));
    }
    else if (iPrintType == I_PRINT_TYPE_STRING)
    {
      sPrintOutput = sPrintOutput + ProcessInput(sInput) + S_EOL;
    };
  }

}
